package com.tsxy.mall.mapper;

import com.tsxy.mall.entity.Recovery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface RecoveryMapper {

    @Insert({" insert into recovery (book_name ,author,name,phone,college,major,details,user) " +
            "values (#{bookName},#{author},#{name},#{phone},#{college},#{major},#{details},#{user})"})
    Integer add(Recovery recovery);

    @Select({"select * from recovery where user = #{user}"})
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "name" ,property = "name"),
            @Result(column = "author", property="author", jdbcType= JdbcType.VARCHAR),
            @Result(column = "bookName" ,property = "bookName"),
            @Result(column = "college" ,property = "bookName"),
            @Result(column = "major" ,property = "bookName"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "details",property = "details"),
            @Result(column = "status",property = "status"),
            @Result(column = "time",property = "time"),
            @Result(column = "college",property = "collegeE",
                    one = @One(select = "com.tsxy.mall.mapper.CollegeMapper.getByCollegeId")),
            @Result(column = "major",property = "majorE",
                    one = @One(select = "com.tsxy.mall.mapper.CollegeMapper.getByMajorId"))
    })
    List<Recovery> getList(Recovery recovery);
}
